package com.gexiaobao.pigeon.ui.adapter

import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.GetVideoListResponse
import com.gexiaobao.pigeon.databinding.ItemMyVisitVideoBinding
import com.makeramen.roundedimageview.RoundedImageView

/**
 * @Author      : hxw
 * @Date        : 2024/6/14 15:56
 * @Describe    :
 */
class AdapterMyVisitVideo(data: ArrayList<GetVideoListResponse.ListData>) :
    BaseQuickAdapter<GetVideoListResponse.ListData, DataBindBaseViewHolder>(R.layout.item_my_visit_video, data) {
    override fun convert(holder: DataBindBaseViewHolder, item: GetVideoListResponse.ListData) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemMyVisitVideoBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val ivVideoPic = holder.getView<RoundedImageView>(R.id.ivVideoPic)
        Glide.with(context)
            .setDefaultRequestOptions(
                RequestOptions()
                    .frame(0)
                    .centerCrop()
            )
            .load(item.path)
            .apply(RequestOptions.bitmapTransform(RoundedCorners(20)))
            .into(ivVideoPic)
    }
}